import authCheckApp from './authCheckApp'

/**
 * 获取GPS信息
 * @since 1.0.0
 * @returns {Promise} 返回获取到的GPS信息
 * @example
 * 
 * getGps().then(res => {}).catch(err => {})
 */
function getGps() {
    return new Promise((reslove, reject) => {
        authCheckApp()
            .then(success => {
            // 发起请求
                window.WebViewJavascriptBridge.callHandler('getGPS', null, (response) => {
                    if (typeof response === 'string') {
                        response = JSON.parse(response)
                    }
                    if (response.status === 0) {
                        reslove(response)
                    } else {
                        reject(response)
                    }
                })
            }).catch(err => {
                reject(err)
            })
    })
}

export default getGps